<template>
  <div class="template-form-Lu">
    <a-modal
      title=""
      :visible="applicationFormVisible"
      :maskClosable="false"
      :closable="true"
      :destroyOnClose="true"
      width="100%"
      :dialog-style="{ margin: '0 auto' }"
      wrapClassName="form-modal-Lu"
      @cancel="closeVisible">
      <template slot="footer">
        <div v-if="linkName == '请假确认'">
            <a-button @click="onSubmit('提交')" class="blue-btn">
                确认请假
            </a-button>
        </div>
        <div v-else-if="linkName == '数据修订'">
            <a-button @click="editForm" class="blue-btn">
                确认修订
            </a-button>
        </div>
        <div v-else-if="linkName=='流程监控'||linkName=='请休假统计'||linkName=='我的已办'">
            <a-button @click="closeVisible">
                关闭
            </a-button>
        </div>
        <div v-else>
            <a-button @click="onSave('保存')">
                保存
            </a-button>
            <a-button :loading="loading" class="blue-btn" @click="onSubmit('提交')">
                提交
            </a-button>
            <!-- <a-button class="blue-btn" @click="resetForm">
                重置
            </a-button> -->
            <a-button class="red-btn" @click="returnClick" v-if="linkName!=='请假申请'">
                退回
            </a-button>
        </div>
      </template>
      <a-tabs type="card" v-if="applicationFormVisible" @change="callback">
        <a-tab-pane key="1" tab="申请表">
          <div id="printTest" class="print-div-shu">
            <a-form-model
              ref="ruleForm"
              :model="form"
              :rules="fRules()"
              :label-col="labelCol"
              :wrapper-col="wrapperCol"
              class=""
            >
              <h1 class="h1-page">自治区食品药品审评查验中心<br/>干部职工请休假申请登记表</h1>
              <table border="1" cellspacing="0" class="table-Lu qxj-table">
                <tr v-if="linkName!=='请假申请'&&linkName !== '数据修订'">
                  <th>姓名</th>
                    <td colspan="2">{{ form.fxm }}</td>
                  <th>部门</th>
                    <td colspan="2">{{ form.fbm }}</td>
                </tr>
                <!-- <tr v-if="linkName!=='请假申请'&&linkName !== '数据修订'">
                  <th>职务</th>
                    <td>{{ form.fzw }}</td>
                  <th>是否离市</th>
                    <td>{{ form.fsflkbgzdszcs == true?'是':'否' }}</td>
                </tr> -->
                <tr v-if="linkName=='请假申请'">
                  <th>年度信息</th>
                  <td colspan="5">
                    <a-form-model-item>
                      <p>{{ fndxx }}</p>
                    </a-form-model-item>
                  </td>
                </tr>
                <tr>
                  <th>休假类型</th>
                  <td colspan="2" v-if="linkName=='请假申请' || linkName == '数据修订'">
                    <a-form-model-item ref="fqjlx" prop="fqjlx">
                      <a-select
                        v-model="form.fqjlx"
                        placeholder="please select your zone"
                        @change="fqjlxChange"
                        style="width: 100%;">
                        <a-select-option
                          v-for="(item,index) in qjlxList"
                          :key="index"
                          :value="item.itemValue">
                          {{ item.itemText }}
                        </a-select-option>
                      </a-select>
                    </a-form-model-item>
                  </td>
                  <td v-else colspan="2">{{ form.fqjlx }}</td>
                  <th>休假天数</th>
                  <td colspan="2" v-if="linkName=='请假申请'  || linkName == '数据修订'">
                    <a-form-model-item ref="fts" prop="fts">
                      <a-input
                        disabled
                        placeholder="自动计算，无需填写"
                        v-model="form.fts"
                        style="font-size:20px;margin-bottom: 0px">
                        <!-- {{ form.fts }} -->
                      </a-input>
                    </a-form-model-item>
                  </td>
                  <td v-else colspan="2">{{ form.fts }} 天</td>
                </tr>
                <tr v-if="isBj">
                  <td colspan="6">
                    <a-form-model-item
                      ref="fsfnnxq"
                      label="是否拿年休假抵假"
                      prop="fsfnnxq">
                      <a-switch
                        v-model="form.fsfnnxq"
                        @change="sfnnxqChange"/>
                    </a-form-model-item>
                  </td>
                </tr>
                <tr v-if="isQjsm">
                  <th>请假说明</th>
                  <td colspan="5">
                    <p style="color: red;">{{ form.fqjsm }}</p>
                  </td>
                </tr>
                <tr>
                  <th>开始日期</th>
                    <td v-if="linkName=='请假申请' || linkName == '数据修订'" colspan="2">
                        <a-form-model-item ref="fqjkssj" prop="fqjkssj">
                        <a-input-group compact>
                            <a-date-picker
                                style="width: 60%"
                                v-model="form.fqjkssj"
                                type="date"
                                placeholder=""
                                @change="date1Change"/>
                            <a-select
                                style="width: 40%"
                                default-value="08:00"
                                v-model="form.fqjksxs"
                                @change="time1Change">
                                <a-select-option value="08:00">
                                    08:00
                                </a-select-option>
                                <a-select-option value="12:00">
                                    12:00
                                </a-select-option>
                                <a-select-option value="18:00">
                                    18:00
                                </a-select-option>
                            </a-select>
                        </a-input-group>
                        </a-form-model-item>
                    </td>
                  <td v-else colspan="2">{{ form.fqjkssj }}</td>
                  <th>结束日期</th>
                  <td v-if="linkName=='请假申请' || linkName == '数据修订'" colspan="2">
                        <a-form-model-item ref="fqjjssj" prop="fqjjssj">
                            <a-input-group compact>
                                <a-date-picker
                                    style="width: 60%"
                                    v-model="form.fqjjssj"
                                    type="date"
                                    placeholder=""
                                    @change="date2Change"/>
                                    <a-select
                                    style="width: 40%;"
                                    default-value="18:00"
                                    v-model="form.fqjjsxs"
                                    @change="time2Change">
                                <a-select-option value="08:00">
                                    08:00
                                </a-select-option>
                                <a-select-option value="12:00">
                                    12:00
                                </a-select-option>
                                <a-select-option value="18:00">
                                    18:00
                                </a-select-option>
                                </a-select>
                            </a-input-group>
                        </a-form-model-item>
                  </td>
                  <td v-else colspan="2">{{ form.fqjjssj }}</td>
                </tr>
                <tr>
                  <th>休假原因</th>
                  <td colspan="5">
                    <a-form-model-item v-if="linkName=='请假申请' || linkName == '数据修订'" ref="fyy" prop="fyy">
                      <a-textarea v-model="form.fyy" :auto-size="{ minRows: 2}" placeholder="请输入请休假原因"/>
                    </a-form-model-item>
                    <p v-else class="text-align-left">{{ form.fyy }}</p>
                  </td>
                </tr>
                <tr v-if="linkName=='请假申请' || linkName=='数据修订'">
                  <th>证明材料</th>
                  <td colspan="5">
                    <div>
                      <a-form layout="inline" style="display: flex;justify-content: flex-start;">
                        <a-form-item class="vxe-table-box-w" >
                            <a-upload style="display: inline-block;" :beforeUpload="beforeUpload" action="" @change="uploadClick">
                                <a-button class="blue-btn">上传文件</a-button>
                            </a-upload>
                        </a-form-item>
                      </a-form>
                      <a-list item-layout="horizontal" :data-source="filesListData">
                        <a-list-item slot="renderItem" slot-scope="item, index">
                          <a-list-item-meta>
                            <a @click="openFiles(item)" slot="title" href="#">{{ item.fmc }}</a>
                          </a-list-item-meta>
                          <a-button style="margin-right: 10px;" class="blue-btn" @click="openFiles(item)" >预览</a-button>
                          <a-button style="margin-right: 10px;" class="blue-btn" @click="downloadFiles(item)" >下载文件</a-button>
                          <a-button
                            class="red-btn"

                            style="margin-right: 10px;"
                            @click="deleteFiles(item.id)" >
                            删除文件
                          </a-button>
                        </a-list-item>
                      </a-list>
                    </div>
                  </td>
                </tr>
                <tr>
                    <th>科室负责人意见</th>
                    <td v-if="linkName == '科室审批' || linkName == '数据修订'" colspan="5">
                        <a-form-model-item ref="fksyj" prop="fksyj">
                                <reviewOpinions
                                  ref="reviewOpinionsRefKs"
                                  @getInputOpinion="getInputOpinion"
                                  @openOpinions="ksOpinions"
                                  v-decorator="[
                                        'fksyj', {initialValue:form.fksyj,rules: rules.fksyj}]"/>
                        </a-form-model-item>
                        <div v-if="linkName == '数据修订'" class="yjqm-right-bottom">
                            <a-input
                                @click="checkMan('fksqm',form.fksqm)"
                                v-model="form.fksqm"
                                class="checkMan-Xiu"
                                placeholder="指定科室待办人">
                            </a-input>
                            <a-date-picker
                                show-time
                                placeholder="科室负责人意见时间："
                                v-model="form.fksqmsj"
                                @change="timeChang($event,'fksqmsj')"
                                class="checkTime-Xiu"/>
                            </div>
                    </td>
                    <td v-else colspan="5">
                        <p class="text-align-left">{{ form.fksyj }}</p>
                        <div class="yjqm-right-bottom">
                            <img v-if="getUrl('科室审批') && form.fksqmsj" :src="getUrl('科室审批')" alt="" class="yjqmImg"/>
                            <span v-else class="yjqmImg">{{ form.fksqm }}</span>
                            <span>{{ form.fksqmsj }}</span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>办公室审批意见</th>
                    <td v-if="linkName == '人事审批' || linkName == '数据修订'" colspan="5">
                        <a-form-model-item ref="frsyj" prop="frsyj">
                            <reviewOpinions
                              ref="reviewOpinionsRefBgs"
                              @getInputOpinion="getInputOpinion"
                              @openOpinions="bgsOpinions"
                              v-decorator="[
                                'frsyj', {initialValue:form.frsyj,rules: rules.frsyj}]"/>
                        </a-form-model-item>
                        <div v-if="linkName == '数据修订'" class="yjqm-right-bottom">
                            <a-input
                                @click="checkMan('frsqm',form.frsqm)"
                                v-model="form.frsqm"
                                class="checkMan-Xiu"
                                placeholder="指定办公室待办人">
                            </a-input>
                            <a-date-picker
                                show-time
                                placeholder="办公室负责人意见时间："
                                v-model="form.frsqmsj"
                                @change="timeChang($event,'frsqmsj')"
                                class="checkTime-Xiu"/>
                        </div>
                    </td>
                    <td v-else colspan="5">
                        <p class="text-align-left">{{ form.frsyj }}</p>
                        <div class="yjqm-right-bottom">
                            <img v-if="getUrl('人事审批') && form.frsqmsj" :src="getUrl('人事审批')" alt="" class="yjqmImg"/>
                            <span v-else class="yjqmImg">{{ form.frsqm }}</span>
                            <span>{{ form.frsqmsj }}</span>
                        </div>
                    </td>
                </tr>
                <tr>
                  <th>中心分管领导意见</th>
                  <td v-if="linkName == '分管审批' || linkName == '数据修订'" colspan="5">
                        <a-form-model-item ref="ffgyj" prop="ffgyj">
                            <reviewOpinions
                              ref="reviewOpinionsRefFg"
                              @getInputOpinion="getInputOpinion"
                              @openOpinions="fgOpinions"
                              v-decorator="[
                                'ffgyj', {initialValue:form.ffgyj,rules: rules.ffgyj}]"/>
                        </a-form-model-item>
                        <div v-if="linkName == '数据修订'" class="yjqm-right-bottom">
                            <a-input
                                @click="checkMan('ffgqm',form.ffgqm)"
                                v-model="form.ffgqm"
                                class="checkMan-Xiu"
                                placeholder="指定中心分管领导">
                            </a-input>
                            <a-date-picker
                                show-time
                                placeholder="中心分管领导意见时间："
                                v-model="form.ffgqmsj"
                                @change="timeChang($event,'ffgqmsj')"
                                class="checkTime-Xiu"/>
                        </div>
                    </td>
                    <td v-else colspan="5">
                        <p class="text-align-left">{{ form.ffgyj }}</p>
                        <div class="yjqm-right-bottom">
                            <img v-if="getUrl('分管审批') && form.ffgqmsj" :src="getUrl('分管审批')" alt="" class="yjqmImg"/>
                            <span v-else class="yjqmImg">{{ form.ffgqm }}</span>
                            <span>{{ form.ffgqmsj }}</span>
                        </div>
                    </td>
                </tr>
                <tr>
                  <th>中心主要领导意见</th>
                  <td v-if="linkName == '中心领导审批' || linkName == '数据修订'" colspan="5">
                        <a-form-model-item ref="fzxyj" prop="fzxyj">
                            <reviewOpinions
                              ref="reviewOpinionsRefZxld"
                              @getInputOpinion="getInputOpinion"
                              @openOpinions="zxldOpinions"
                              v-decorator="[
                                'fzxyj', {initialValue:form.fzxyj,rules: rules.fzxyj}]"/>
                        </a-form-model-item>
                        <div v-if="linkName == '数据修订'" class="yjqm-right-bottom">
                            <a-input
                                @click="checkMan('fzxqm',form.fzxqm)"
                                v-model="form.fzxqm"
                                class="checkMan-Xiu">
                            </a-input>
                            <a-date-picker
                                show-time
                                placeholder="中心主要领导意见时间："
                                v-model="form.fzxqmsj"
                                @change="timeChang($event,'fzxqmsj')"
                                class="checkTime-Xiu"/>
                        </div>
                    </td>
                    <td v-else colspan="5">
                        <p class="text-align-left">{{ form.fzxyj }}</p>
                        <div class="yjqm-right-bottom">
                            <img v-if="getUrl('中心领导审批') && form.fzxqmsj" :src="getUrl('中心领导审批')" alt="" class="yjqmImg"/>
                            <span v-else class="yjqmImg">{{ form.fzxqm }}</span>
                            <span>{{ form.fzxqmsj }}</span>
                        </div>
                    </td>
                </tr>
                <tr>
                  <th>备注</th>
                  <td colspan="5" v-if="linkName == '请假申请' || linkName == '数据修订'">
                    <a-input v-model="form.fbz" placeholder="请输入备注" type="textarea" />
                  </td>
                  <td v-else colspan="5" style="text-align:left;">{{ form.fbz }}</td>
                </tr>
                <tr>
                  <td colspan="6">
                    <p class="text-align-left" style="line-height: 2;">
                      1.请假1日以内(含1日)须本科室负责人审核，人事部门签署意见，
                      报分管领导批准。请假1日以上须加报中心主任批准。<br/>
                      2.各科室负责人请假须经由中心分管领导签署意见，中心主任批准。<br/>
                      3.请休假审批表统一交中心办公室保存。
                    </p>
                  </td>
                </tr>
              </table>
            </a-form-model>
          </div>
        </a-tab-pane>
        <a-tab-pane v-if="linkName == '我的已办'" key="2" tab="流转记录">
          <a-table
            :columns="lzColumns"
            :data-source="lzList"
            bordered
            style="border-color: #d9d9d9;font-weight: 600;text-align: center;"
            :customRow="customRow">
          </a-table>
        </a-tab-pane>
        <a-tab-pane key="3" v-if="linkName !== '请假申请' && linkName !== '数据修订'" tab="表单附件">
          <a-table
            :columns="fjColumns"
            :data-source="filesListData"
            bordered
            style="border-color: #d9d9d9;font-weight: 600;text-align: center;"
            :customRow="customRow">
            <span slot="operation_btn" slot-scope="text, record">
              <a-button  class="blue-btn" @click="openFiles(record)" style="margin-right: 10px;">查看</a-button>
              <a-button  class="blue-btn" @click="downloadFiles(record)">下载</a-button>
            </span>
          </a-table>
        </a-tab-pane>
        <a-button
            v-if="showPrintBtn(linkName,form.flczt,tabsKey)"
          slot="tabBarExtraContent"
          class="print-btn"
          v-print="printObj">
          打印
        </a-button>
      </a-tabs>
    </a-modal>
    <a-modal
      title="提示"
      :visible="messageVisible"
      @ok="messageVisible = false"
      @cancel="messageVisible = false"
    >
      <p>您本年度年假已休完，不能再申请年假，
        如有疑问请联系人事处！</p>
    </a-modal>
    <personnelList ref="personnelListRef" :modaObj="modaObj" @checkPersonnel="checkPersonnel"></personnelList>
  </div>
</template>
<script>
import {myndxx,initBzFlow,ocalityPostAction,myqxsm,saveFlow,submitFlow,flowJkPage,
      fjupload,fjedit,openFile,downLoadOa,fjlist,deleleMinioFile,downMyQm,edit,fjAdd,
      returnUpperzdyFlowJob,queryAllYbJob,rsyjDefault} from './service/index'
import moment from 'moment'
import personnelList from '../../modal/personnelList'
import store from '@/store'
import blobType from '@/common/blobType'
import YchConstant from '@/api/YchConstant'
export default {
    components: {
        personnelList
    },
    props:{
        formData:{
        type:[Array,Object],
        default: () => {},
        required:false
        },
        linkName:{
        type:String,
        default:'',
        required:false,
        },
        // stepNums:{
        //   type:Number,
        //   default: '',
        //   require:false,
        // },
    },
    data() {
        return {
        moment:moment,
        loading: false,
        applicationFormVisible: false,

        labelCol: { span: 8 },
        wrapperCol: { span: 24 },
        other: '',
            tabsKey: '1',
        stepNums: 0,
        fndxx : "",
        kongForm: {},
        form: {
            fbm : "",
            fbz : "",
            ffgqm : "",
            ffgqmsj : "",
            ffgyj : "",
            ffhrq : "",
            fksqm : "",
            fksqmsj : "",
            fksyj : "",
            flczt : "",
            flkrq : "",
            fmdd : "",
            fqjjssj : null,
            fqjkssj : null,
            fqjksxs: "08:00",
            fqjjsxs: "18:00",
            fqjlx : "",
            fqjsm : "",
            fqtjlx : "",
            frsqm : "",
            frsqmsj : "",
            frsyj : "",
            fsffqlc : "",
            fsflkbgzdszcs : false,
            fsfnnxq : false,
            fsjyy : "",
            fts : null,
            fuserid : "",
            fxm : "",
            fyy : "",
            fzw : "",
            fzxqm : "",
            fzxqmsj : "",
            fzxyj : "",
            id : "",
            fuserid: '',
        },
        rules: {
            fqjlx: [
            { required: true, message: '请选择休假类型', trigger: 'change' },
            ],
            fts: [
            { required: true, message: '请输入休假天数', trigger: 'blur' }
            ],
            fqjkssj: [
            { required: true, message: '请选择休假开始日期', trigger: 'change' }
            ],
            fqjjssj: [
            { required: true, message: '请选择休假结束日期', trigger: 'change' },
            ],
            fyy: [
            { required: true, message: '请输入休假原因', trigger: 'blur' }
            ],
        },
        ksRules: {
            fksyj: [
            { required: true, message: '请输入科室负责人意见', trigger: 'blur' }
            ],
        },
        rsRules: {
            frsyj: [
            { required: true, message: '请输入办公室负责人意见', trigger: 'blur' }
            ],
        },
        fgRules: {
            ffgyj: [
            { required: true, message: '请输入中心分管领导意见', trigger: 'blur' }
            ],
        },
        zxRules: {
            fzxyj: [
            { required: true, message: '请输入中心主要领导意见', trigger: 'blur' }
            ],
        },
        isLeaveAdd: false,
        qjlxList: [],
        isQjsm: false,
        isBj: false,
        dayNum: 0,
        messageVisible: false,
        modaObj: {},
        lzColumns: [
            {
            title: '环节名称',
            dataIndex: 'fhjmc',
            key: 'fhjmc',
            width: 150,
            },{
            title: '待办人',
            dataIndex: 'fdbr',
            key: 'fdbr',
            width: 150,
            align: 'center'
            },{
            title: '办理人',
            dataIndex: 'fblr',
            key: 'fblr',
            width: 100,
            },{
            title: '发送时间',
            dataIndex: 'ffssj',
            key: 'ffssj',
            width: 170,
            },{
            title: '办理时间',
            dataIndex: 'fblsj',
            key: 'fblsj',
            width: 170,
            },{
            title: '办理状态',
            dataIndex: 'fblzt',
            key: 'fblzt',
            width: 100,
            },{
            title: '办理类型',
            dataIndex: 'fbllx',
            key: 'fbllx',
            width: 300,
            },{
            title: '办理意见',
            dataIndex: 'fblyj',
            key: 'fblyj',
            align: 'center'
            },
        ],
        lzList: [],
        printObj:{
            id:"printTest", //需要打印的id名称
            popTitle:"干部职工离岗请休假登记表",//文档的名称
            // preview:true,//预览功能，不好用
            zIndex:'20002',
            beforeOpenCallback(vue){
                //console.log('打印回调',vue)
            },
            openCallback (vue) {//打开之前
                //console.log('打开之前',vue)
            },
            closeCallback (vue) {//关闭了打印工具
                //console.log('关闭了打印工具')
            },
        },
        filesListData: [],
        fjColumns: [
            {
            title: '文件名',
            dataIndex: 'fmc',
            key: 'fmc',
            align: 'center'
            },{
            title: '文件类型',
            dataIndex: 'fwjlx',
            key: 'fwjlx',
            align: 'center'
            },{
            title: '上传时间',
            dataIndex: 'fscsj',
            key: 'fscsj',
            align: 'center'
            },{
            title: '上传人',
            dataIndex: 'fscr',
            key: 'fscr',
            align: 'center'
            },{
            title: '操作',
            key: 'id',
            scopedSlots: { customRender: 'operation_btn' },
            },
        ],
        imgList: [
            {fhjmc:'科室审批',url: ''},
            {fhjmc:'人事审批',url: ''},
            {fhjmc:'分管审批',url:''},
            {fhjmc:'中心领导审批',url: ''},
            {fhjmc:'请假确认',url: ''},
        ],
        }
    },
    created() {
        this.kongForm = JSON.parse(JSON.stringify(this.form))
    },
    watch: {
        formData:{
            handler (newval, oldVal) {
                //console.log('newval',newval)
                this.form = newval
                this.form.fts = Number(newval.fts)
                //console.log(this.form)
                this.form.fsfnnxq = this.form.fsfnnxq == '是'?true:false,
                this.form.fsflkbgzdszcs = this.form.fsflkbgzdszcs == '是'?true:false
                // 是否离开办公驻地所在城市
                if(this.form.fsflkbgzdszcs == true){
                this.isLeaveAdd = true
                }
                // 休假类型说明
                if(this.linkName == '请假申请'){
                  this.fqjlxChange(this.form.fqjlx)
                }
                if(this.linkName == '人事审批'){
                  if(!this.form.frsyj){
                    this.getRsyjDefault()
                  }
                }
                // 流转记录
                let id = ''
                if(this.form.oaid == undefined){
                id = this.form.id
                } else {
                id = this.form.oaid
                }
                flowJkPage({oaid:id}).then(res => {
                let arr1 = []
                    arr1 = res.result.records
                var arr2 = new Array();
                for (let i = arr1.length - 1; i >= 0; i--) {
                    arr2.push(arr1[i]);
                }
                this.lzList = []
                arr1.forEach(item => {
                    item = {
                    ...item,
                    key: item.jobid
                    }
                    this.lzList.push(item)
                    this.imgList.forEach((items,a)=> {
                    if(item.fdbrid){
                        if(items.fhjmc == item.fhjmc){
                          downMyQm({id:item.fdbrid}).then(resa => {
                            if(resa.code){
                              this.imgList[a].url = null
                            } else {
                              this.imgList[a].url = "data:image/png;base64," +
                              btoa( new Uint8Array(resa).reduce( (data, byte) => data + String.fromCharCode(byte), "" ))
                            }
                          })
                        }
                    } else {}
                    })
                })
                })
                // 附件
                fjlist({foaid:id}).then(res => {
                this.filesListData = []
                this.filesListData = res.result.records
                // //console.log(this.filesListData)
                })
            }
        },
        applicationFormVisible(newval, oldVal){
            if(newval == true && this.linkName == '请假申请'){
                this.getMyndxx()
                this.getOcalityPostAction()
            }
        },
        deep: true,
    },
    activated() {
        this.$nextTick(_ => {
          if(this.linkName == '请假申请'){
            this.getMyndxx() //更新年度信息
            this.getOcalityPostAction() // OA请休假类型
          }
        })
    },
    methods: {
        showPrintBtn(linkName,flczt,tabsKey){
            if(linkName == '我的已办' && flczt == '流程结束' && tabsKey == '1'){
                return true
            } else {
                return false
            }
        },
        closeVisible(){
            this.$emit('success')
            this.applicationFormVisible = false
            this.resetForm()
        },
        // 办公室环节意见自动填写
        getRsyjDefault(){
          rsyjDefault({oaid: this.form.oaid}).then(res => {
            if(res.success){
              this.form.frsyj = res.message
              this.bgsOpinions()
            }
          })
        },
        callback(key) {
        // //console.log(key);
            this.tabsKey = key
        },
        fRules(){
            let data = {}
            if(this.linkName == '请假申请'){
                data = this.rules
            } else if(this.linkName == '科室审批'){
                data = this.ksRules
            } else if(this.linkName == '人事审批'){
                data = this.rsRules
            } else if(this.linkName == '分管审批'){
                data = this.fgRules
            } else if(this.linkName == '中心领导审批'){
                data = this.zxRules
            }
            return data
        },
        onSave(str) {
          let data = {}
          let data1 = {}
          // //console.log(this.form.fsfnnxq)
          if(this.linkName == '请假申请'){
              if(this.form.id){
                  data1 = {
                          fqjlx: this.form.fqjlx,
                          fts: this.form.fts.toString(),
                          fsfnnxq: this.form.fsfnnxq == true?'是':'否',
                          fyy: this.form.fyy,
                          fqjkssj: this.form.fqjkssj,
                          fqjjssj: this.form.fqjjssj,
                          fqjksxs: this.form.fqjksxs,
                          fqjjsxs: this.form.fqjjsxs,
                          fsflkbgzdszcs: this.form.fsflkbgzdszcs == true?'是':'否',
                          flkrq: this.form.flkrq==''?'':moment(this.form.flkrq).format('YYYY-MM-DD'),
                          ffhrq: this.form.ffhrq==''?'':moment(this.form.ffhrq).format('YYYY-MM-DD'),
                          id: this.form.id,
                          fuserid: this.form.fuserid,
                      }
                  if(str == '保存'){
                      initBzFlow(data1).then(res => {
                          if(res.code == 200){
                              this.$message.success(res.message)
                              this.form = {
                                  ...res.result.oaMap,
                                  jobid: res.result.jobMap.id
                              }
                              this.form.fsfnnxq = this.form.fsfnnxq == '是'?true:false,
                              this.form.fsflkbgzdszcs = this.form.fsflkbgzdszcs == '是'?true:false,
                              this.form.id = res.result.oaMap.id//赋值
                              this.fqjlxChange(this.form.fqjlx)
                          } else {
                              this.$message.error(res.message)
                          }
                      })
                  } else if(str == '提交'){
                    this.loading = true
                      initBzFlow(data1).then(res => {
                          if(res.code == 200){
                              // this.$message.success(res.message)
                              this.form = {
                                  ...res.result.oaMap,
                                  jobid: res.result.jobMap.id
                              }
                              this.form.fsfnnxq = this.form.fsfnnxq == '是'?true:false,
                              this.form.fsflkbgzdszcs = this.form.fsflkbgzdszcs == '是'?true:false,
                              this.form.id = res.result.oaMap.id//赋值

                              data = {
                                  jobid: this.form.jobid,
                                  oaid: this.form.id,
                                  map: {
                                      fqjlx: this.form.fqjlx,
                                      fts: this.form.fts.toString(),
                                      fsfnnxq: this.form.fsfnnxq == true?'是':'否',
                                      fyy: this.form.fyy,
                                      fqjkssj: this.form.fqjkssj,
                                      fqjjssj: this.form.fqjjssj,
                                      fqjksxs: this.form.fqjksxs,
                                      fqjjsxs: this.form.fqjjsxs,
                                      fsflkbgzdszcs: this.form.fsflkbgzdszcs == true?'是':'否',
                                      flkrq: this.form.flkrq==''?'':moment(this.form.flkrq).format('YYYY-MM-DD'),
                                      ffhrq: this.form.ffhrq==''?'':moment(this.form.ffhrq).format('YYYY-MM-DD'),
                                  },
                                  opinion: '',
                              }

                              submitFlow(data).then(res => {
                                  if(res.code == 200){
                                      this.$message.success(res.message)
                                      this.closeVisible()
                                  } else {
                                  this.$message.warning(res.message)
                                  }
                                  this.loading = false
                              })
                          } else {
                              this.$message.error(res.message)
                          }
                      })
                  }
              } else {
                  data = {
                      fqjlx: this.form.fqjlx,
                      fts: this.form.fts.toString(),
                      fsfnnxq: this.form.fsfnnxq == true?'是':'否',
                      fyy: this.form.fyy,
                      fqjkssj: this.form.fqjkssj,
                      fqjjssj: this.form.fqjjssj,
                      fqjksxs: this.form.fqjksxs,
                      fqjjsxs: this.form.fqjjsxs,
                      fsflkbgzdszcs: this.form.fsflkbgzdszcs == true?'是':'否',
                      flkrq: this.form.flkrq==''?'':moment(this.form.flkrq).format('YYYY-MM-DD'),
                      ffhrq: this.form.ffhrq==''?'':moment(this.form.ffhrq).format('YYYY-MM-DD'),
                      id: this.form.id,
                      // fuserid: store.getters.userInfo.id
                  }
                  if(str == '提交'){
                      data = {
                          ...data,
                          fsffqlc: '是'
                      }
                      this.loading = true
                  }
                  initBzFlow(data).then(res => {
                      if(res.code == 200){
                          this.$message.success(res.message)
                          if(str == '提交'){
                              this.closeVisible()
                          } else {
                              this.form = {
                                  ...res.result.oaMap,
                                  jobid: res.result.jobMap.id
                              }
                              this.form.fsfnnxq = this.form.fsfnnxq == '是'?true:false,
                              this.form.fsflkbgzdszcs = this.form.fsflkbgzdszcs == '是'?true:false,
                              this.form.id = res.result.oaMap.id//赋值
                              this.fqjlxChange(this.form.fqjlx)
                          }
                      } else {
                          this.$message.error(res.message)
                      }
                      this.loading = false
                  })
              }
          } else if (this.linkName == '科室审批'){
              data = {
                  jobid: this.form.jobid,
                  oaid: this.form.oaid,
                  map: {
                  fksyj: this.form.fksyj,
                  fksqm: this.form.fksqm,
                  fksqmsj: this.form.fksqmsj,
                  },
                  opinion: this.form.fksyj,
              }
          } else if (this.linkName == '人事审批'){
              data = {
              jobid: this.form.jobid,
              oaid: this.form.oaid,
              map: {
                  frsyj: this.form.frsyj,
                  frsqm: this.form.frsqm,
                  frsqmsj: this.form.frsqmsj
              },
              opinion: this.form.fksyj,
              }
          } else if (this.linkName == '分管审批'){
              data = {
              jobid: this.form.jobid,
              oaid: this.form.oaid,
              map: {
                  ffgyj: this.form.ffgyj,
                  ffgqm: this.form.ffgqm,
                  ffgqmsj: this.form.ffgqmsj
              },
              opinion: this.form.ffgyj,
              }
          } else if (this.linkName == '中心领导审批'){
              data = {
              jobid: this.form.jobid,
              oaid: this.form.oaid,
              map: {
                  fzxyj: this.form.fzxyj,
                  fzxqm: this.form.fzxqm,
                  fzxqmsj: this.form.fzxqmsj
              },
              opinion: this.form.fzxyj,
              }
          } else if (this.linkName == '请假确认'){
              data = {
              jobid: this.form.jobid,
              oaid: this.form.oaid,
              map: {
                  fsfqrqj: '是',
              },
              opinion: '是',
              }
          }
          data = {
              ...data,
              nextNode: "",
              nextNodeId: "",
              smgflag: "",
              currentNode: "",
              dbrid: "",
              lcmbCode: "",
          }
              if(str == '保存' && this.linkName !== '请假申请'){
                  saveFlow(data).then(res => {
                      if(res.code == 200){
                      this.$message.success(res.message)
                      } else {
                      this.$message.warning(res.message)
                      }
                  })
              } else if(str == '提交' && this.form.id && this.form.jobid && this.linkName !== '请假申请'){
                  submitFlow(data).then(res => {
                      if(res.code == 200){
                      this.$message.success(res.message)
                      this.closeVisible()
                      } else {
                      this.$message.warning(res.message)
                      }
                  })
              }
        },
        // 提交
        onSubmit(str) {
            // //console.log(this.form)
            this.$refs.ruleForm.validate(valid => {
                //console.log(valid)
                if(valid) {
                    var that = this
                    that.$confirm({
                        title: '您确定要提交吗?',
                        onOk() {
                            let data = {}
                            let data1 = {}
                            // //console.log(that.form.fsfnnxq)
                            if(that.linkName == '请假申请'){
                                if(that.form.id){
                                    data1 = {
                                            fqjlx: that.form.fqjlx,
                                            fts: that.form.fts.toString(),
                                            fsfnnxq: that.form.fsfnnxq == true?'是':'否',
                                            fyy: that.form.fyy,
                                            fqjkssj: that.form.fqjkssj,
                                            fqjjssj: that.form.fqjjssj,
                                            fqjksxs: that.form.fqjksxs,
                                            fqjjsxs: that.form.fqjjsxs,
                                            fsflkbgzdszcs: that.form.fsflkbgzdszcs == true?'是':'否',
                                            flkrq: that.form.flkrq==''?'':moment(that.form.flkrq).format('YYYY-MM-DD'),
                                            ffhrq: that.form.ffhrq==''?'':moment(that.form.ffhrq).format('YYYY-MM-DD'),
                                            id: that.form.id,
                                            fuserid: that.form.fuserid,
                                        }
                                    if(str == '保存'){
                                        initBzFlow(data1).then(res => {
                                            if(res.code == 200){
                                                that.$message.success(res.message)
                                                that.form = {
                                                    ...res.result.oaMap,
                                                    jobid: res.result.jobMap.id
                                                }
                                                that.form.fsfnnxq = that.form.fsfnnxq == '是'?true:false,
                                                that.form.fsflkbgzdszcs = that.form.fsflkbgzdszcs == '是'?true:false,
                                                that.form.id = res.result.oaMap.id//赋值
                                                that.fqjlxChange(that.form.fqjlx)
                                            } else {
                                                that.$message.error(res.message)
                                            }
                                        })
                                    } else if(str == '提交'){
                                    that.loading = true
                                        initBzFlow(data1).then(res => {
                                            if(res.code == 200){
                                                // that.$message.success(res.message)
                                                that.form = {
                                                    ...res.result.oaMap,
                                                    jobid: res.result.jobMap.id
                                                }
                                                that.form.fsfnnxq = that.form.fsfnnxq == '是'?true:false,
                                                that.form.fsflkbgzdszcs = that.form.fsflkbgzdszcs == '是'?true:false,
                                                that.form.id = res.result.oaMap.id//赋值

                                                data = {
                                                    jobid: that.form.jobid,
                                                    oaid: that.form.id,
                                                    map: {
                                                        fqjlx: that.form.fqjlx,
                                                        fts: that.form.fts.toString(),
                                                        fsfnnxq: that.form.fsfnnxq == true?'是':'否',
                                                        fyy: that.form.fyy,
                                                        fqjkssj: that.form.fqjkssj,
                                                        fqjjssj: that.form.fqjjssj,
                                                        fqjksxs: that.form.fqjksxs,
                                                        fqjjsxs: that.form.fqjjsxs,
                                                        fsflkbgzdszcs: that.form.fsflkbgzdszcs == true?'是':'否',
                                                        flkrq: that.form.flkrq==''?'':moment(that.form.flkrq).format('YYYY-MM-DD'),
                                                        ffhrq: that.form.ffhrq==''?'':moment(that.form.ffhrq).format('YYYY-MM-DD'),
                                                    },
                                                    opinion: '',
                                                }

                                                submitFlow(data).then(res => {
                                                    if(res.code == 200){
                                                        that.$message.success(res.message)
                                                        that.closeVisible()
                                                    } else {
                                                    that.$message.warning(res.message)
                                                    }
                                                    that.loading = false
                                                })
                                            } else {
                                                that.$message.error(res.message)
                                            }
                                        })
                                    }
                                } else {
                                    data = {
                                        fqjlx: that.form.fqjlx,
                                        fts: that.form.fts.toString(),
                                        fsfnnxq: that.form.fsfnnxq == true?'是':'否',
                                        fyy: that.form.fyy,
                                        fqjkssj: that.form.fqjkssj,
                                        fqjjssj: that.form.fqjjssj,
                                        fqjksxs: that.form.fqjksxs,
                                        fqjjsxs: that.form.fqjjsxs,
                                        fsflkbgzdszcs: that.form.fsflkbgzdszcs == true?'是':'否',
                                        flkrq: that.form.flkrq==''?'':moment(that.form.flkrq).format('YYYY-MM-DD'),
                                        ffhrq: that.form.ffhrq==''?'':moment(that.form.ffhrq).format('YYYY-MM-DD'),
                                        id: that.form.id,
                                        // fuserid: store.getters.userInfo.id
                                    }
                                    if(str == '提交'){
                                        data = {
                                            ...data,
                                            fsffqlc: '是'
                                        }
                                        that.loading = true
                                    }
                                    initBzFlow(data).then(res => {
                                        if(res.code == 200){
                                            that.$message.success(res.message)
                                            if(str == '提交'){
                                                that.closeVisible()
                                            } else {
                                                that.form = {
                                                    ...res.result.oaMap,
                                                    jobid: res.result.jobMap.id
                                                }
                                                that.form.fsfnnxq = that.form.fsfnnxq == '是'?true:false,
                                                that.form.fsflkbgzdszcs = that.form.fsflkbgzdszcs == '是'?true:false,
                                                that.form.id = res.result.oaMap.id//赋值
                                                that.fqjlxChange(that.form.fqjlx)
                                            }
                                        } else {
                                            that.$message.error(res.message)
                                        }
                                        that.loading = false
                                    })
                                }
                            } else if (that.linkName == '科室审批'){
                                data = {
                                    jobid: that.form.jobid,
                                    oaid: that.form.oaid,
                                    map: {
                                    fksyj: that.form.fksyj,
                                    fksqm: that.form.fksqm,
                                    fksqmsj: that.form.fksqmsj,
                                    },
                                    opinion: that.form.fksyj,
                                }
                            } else if (that.linkName == '人事审批'){
                                data = {
                                jobid: that.form.jobid,
                                oaid: that.form.oaid,
                                map: {
                                    frsyj: that.form.frsyj,
                                    frsqm: that.form.frsqm,
                                    frsqmsj: that.form.frsqmsj
                                },
                                opinion: that.form.fksyj,
                                }
                            } else if (that.linkName == '分管审批'){
                                data = {
                                jobid: that.form.jobid,
                                oaid: that.form.oaid,
                                map: {
                                    ffgyj: that.form.ffgyj,
                                    ffgqm: that.form.ffgqm,
                                    ffgqmsj: that.form.ffgqmsj
                                },
                                opinion: that.form.ffgyj,
                                }
                            } else if (that.linkName == '中心领导审批'){
                                data = {
                                jobid: that.form.jobid,
                                oaid: that.form.oaid,
                                map: {
                                    fzxyj: that.form.fzxyj,
                                    fzxqm: that.form.fzxqm,
                                    fzxqmsj: that.form.fzxqmsj
                                },
                                opinion: that.form.fzxyj,
                                }
                            } else if (that.linkName == '请假确认'){
                                data = {
                                jobid: that.form.jobid,
                                oaid: that.form.oaid,
                                map: {
                                    fsfqrqj: '是',
                                },
                                opinion: '是',
                                }
                            }
                            data = {
                                ...data,
                                nextNode: "",
                                nextNodeId: "",
                                smgflag: "",
                                currentNode: "",
                                dbrid: "",
                                lcmbCode: "",
                            }
                            if(str == '保存' && that.linkName !== '请假申请'){
                                saveFlow(data).then(res => {
                                    if(res.code == 200){
                                    that.$message.success(res.message)
                                    } else {
                                    that.$message.warning(res.message)
                                    }
                                })
                            } else if(str == '提交' && that.form.id && that.form.jobid && that.linkName !== '请假申请'){
                                submitFlow(data).then(res => {
                                    if(res.code == 200){
                                    that.$message.success(res.message)
                                    that.closeVisible()
                                    } else {
                                    that.$message.warning(res.message)
                                    }
                                })
                            }
                            //  else {
                            //         let data1 = {
                            //             fqjlx: that.form.fqjlx,
                            //             fts: that.form.fts,
                            //             fsfnnxq: that.form.fsfnnxq == true?'是':'否',
                            //             fyy: that.form.fyy,
                            //             fqjkssj: that.form.fqjkssj,
                            //             fqjjssj: that.form.fqjjssj,
                            //             fqjksxs: that.form.fqjksxs,
                            //             fqjjsxs: that.form.fqjjsxs,
                            //             fsflkbgzdszcs: that.form.fsflkbgzdszcs == true?'是':'否',
                            //             flkrq: that.form.flkrq==''?'':moment(that.form.flkrq).format('YYYY-MM-DD'),
                            //             ffhrq: that.form.ffhrq==''?'':moment(that.form.ffhrq).format('YYYY-MM-DD'),
                            //             id: that.form.id,
                            //             fuserid: that.form.fuserid,
                            //         }
                            //         initBzFlow(data1).then(res => {
                            //             that.form = {
                            //                 ...res.result.oaMap,
                            //                 jobid: res.result.jobMap.id
                            //             }
                            //             // that.form.fsfnnxq = that.form.fsfnnxq == '是'?true:false,
                            //             // that.form.fsflkbgzdszcs = that.form.fsflkbgzdszcs == '是'?true:false,
                            //             // that.form.id = res.result.oaMap.id//赋值

                            //             let data2 = {
                            //                 jobid: that.form.jobid,
                            //                 oaid: that.form.id,
                            //                 map: {
                            //                     fqjlx: that.form.fqjlx,
                            //                     fts: that.form.fts,
                            //                     fsfnnxq: that.form.fsfnnxq == true?'是':'否',
                            //                     fyy: that.form.fyy,
                            //                     fqjkssj: that.form.fqjkssj,
                            //                     fqjjssj: that.form.fqjjssj,
                            //                     fqjksxs: that.form.fqjksxs,
                            //                     fqjjsxs: that.form.fqjjsxs,
                            //                     fsflkbgzdszcs: that.form.fsflkbgzdszcs == true?'是':'否',
                            //                     flkrq: that.form.flkrq==''?'':moment(that.form.flkrq).format('YYYY-MM-DD'),
                            //                     ffhrq: that.form.ffhrq==''?'':moment(that.form.ffhrq).format('YYYY-MM-DD'),
                            //                 },
                            //                 opinion: '',
                            //             }
                            //             submitFlow(data2).then(res => {
                            //                 if(res.code == 200){
                            //                     that.$message.success(res.message)
                            //                     that.closeVisible()
                            //                 } else {
                            //                     that.$message.warning(res.message)
                            //                 }
                            //             })
                            //         })
                            //     }

                        },
                        onCancel() {},
                    });
                } else {
                    //console.log('error submit!!');
                    return false;
                }
            });
        },
        // 重置
        resetForm() {
            //console.log('清空')
            this.$refs.ruleForm.resetFields();
            this.form = JSON.parse(JSON.stringify(this.kongForm))
            this.filesListData = []
            this.isBj = false
            //console.log(this.form)
        },
        // 休假类型
        fqjlxChange(value){
            //console.log(value)
            if(value == '事假' || value == '病假'){
                this.isBj = true
            } else {
                this.isBj = false
            }
            let data = {
                njdbj: this.form.fsfnnxq,
                qxlx: this.form.fqjlx,
                ts: this.form.fts
            }
            myqxsm(data).then(res => {
              if(res.success){
                this.form.fqjsm = res.result.message
                if(this.form.fqjsm == ''){
                  this.isQjsm = false
                } else {
                  this.isQjsm = true
                }
              }
            })
        },
        myqxsmChange(){
            if(this.form.fqjlx){
                this.fqjlxChange(this.form.fqjlx)
            }
        },
        //
        sfnnxqChange(value){
            if(value == true){
                if(this.dayNum == 0){
                this.messageVisible = true
                this.form.fsfnnxq = false
                }
            }
        },
        // 是否离开办公驻地所在城市
        fsflkbgzdszcsChange(value){
            if(value == true){
                this.isLeaveAdd = true
            } else {
                this.isLeaveAdd = false
            }
        },
        getMyndxx(){
            myndxx().then(res => {
              if(res.success){
                // //console.log('更新年度信息updated',res)
                if(res.result){
                  let data = res.result.result
                  this.dayNum = data.fnxjsyts
                  this.fndxx = "本年度可休年假：" + data.fnxjkxts + "天，" + "已休：" + data.fnxjyxts + "天，" + "剩余：" + data.fnxjsyts + "天"
                }
              }
            })
        },
        getOcalityPostAction(){
            ocalityPostAction({dictName:'OA请休假类型'}).then(res => {
                // //console.log(res)
                this.qjlxList = res.result
            })
        },
        //
        date1Change(val){
            this.form.fqjkssj = val==null?null:moment(val).format('YYYY-MM-DD')
            this.timeChange()
        },
        date2Change(val){
            this.form.fqjjssj = val==null?null:moment(val).format('YYYY-MM-DD')
            this.timeChange()
        },
        time1Change(val){
            this.timeChange()
        },
        time2Change(val){
            this.timeChange()
        },
        timeChange(){
            //console.log('=============',this.form.fqjkssj,this.form.fqjjssj)
            if(this.form.fqjkssj !== null && this.form.fqjjssj !==null){
                let start = new Date(Date.parse(this.form.fqjkssj));
                let end = new Date(Date.parse(this.form.fqjjssj));
                let diff = end.getTime() - start.getTime();// 两个日期相差的毫秒数
                let days = Math.floor(diff / (1000 * 60 * 60 * 24))
                let time1 = Number(this.form.fqjksxs.substr(0,2))
                let time2 = Number(this.form.fqjjsxs.substr(0,2))
                let time3 = time1 + time2
                let time = 0
                if(days == 0){
                if(this.form.fqjksxs == '08:00'){
                    if(this.form.fqjjsxs == '08:00'){
                    this.$message.error('当前选择天数为0，请重新选择！')
                    } else if(this.form.fqjjsxs == '12:00'){
                    time = 0.5
                    } else if(this.form.fqjjsxs == '18:00'){
                    time = 1
                    }
                } else if(this.form.fqjksxs == '12:00'){
                    if(this.form.fqjjsxs == '08:00'){
                    this.$message.error('当前选择天数为0，请重新选择！')
                    } else if(this.form.fqjjsxs == '12:00'){
                    time = 0
                    } else if(this.form.fqjjsxs == '18:00'){
                    time = 0.5
                    }
                } else if(this.form.fqjksxs == '18:00'){
                    if(this.form.fqjjsxs == '08:00'){
                    this.$message.error('当前选择天数为0，请重新选择！')
                    } else if(this.form.fqjjsxs == '12:00'){
                    this.$message.error('当前选择天数为0，请重新选择！')
                    } else if(this.form.fqjjsxs == '18:00'){
                    time = 0
                    }
                }
                } else {
                if(this.form.fqjksxs == '08:00'){
                    if(this.form.fqjjsxs == '08:00'){
                    time = 0
                    } else if(this.form.fqjjsxs == '12:00'){
                    time = 0.5
                    } else if(this.form.fqjjsxs == '18:00'){
                    time = 1
                    }
                } else if(this.form.fqjksxs == '12:00'){
                    if(this.form.fqjjsxs == '08:00'){
                    time = -0.5
                    } else if(this.form.fqjjsxs == '12:00'){
                    time = 0
                    } else if(this.form.fqjjsxs == '18:00'){
                    time = 0.5
                    }
                } else if(this.form.fqjksxs == '18:00'){
                    if(this.form.fqjjsxs == '08:00'){
                    if(days == 1){
                        this.$message.error('当前选择天数为0，请重新选择！')
                        time = -1
                    } else {
                        time = 0
                    }
                    } else if(this.form.fqjjsxs == '12:00'){
                    if(days == 1){
                        time = -0.5
                    } else {
                        time = 0
                    }
                    } else if(this.form.fqjjsxs == '18:00'){
                    time = 0
                    }
                }
                }
                let data = days + time
                if(data <= 0){
                  this.$message.warning('休假天数需大于0，当前天数为'+data+'天，请重新选择')
                  this.form.fts = ''
                  return
                }
                if (Number(data) && data % 1 === 0 && data >= 0){
                    data = data + '.0'
                }
                this.form.fts = data
                //console.log(this.form.fts)
            } else {
                this.form.fts = ''
            }
        },
        // 打开意见弹窗
        ksOpinions(){
            this.$refs.reviewOpinionsRefKs.getData({opinionType:'ksIdeaType',oldVal:this.form.fksyj,valueData:{hjmc:'fksyj'}})
        },
        bgsOpinions(){
            this.$refs.reviewOpinionsRefBgs.getData({opinionType:'bgsIdeaType',oldVal:this.form.frsyj,valueData:{hjmc:'frsyj'}})
        },
        fgOpinions(){
            this.$refs.reviewOpinionsRefFg.getData({opinionType:'fgIdeaType',oldVal:this.form.ffgyj,valueData:{hjmc:'ffgyj'}})
        },
        zxldOpinions(){
            this.$refs.reviewOpinionsRefZxld.getData({opinionType:'zxldIdeaType',oldVal:this.form.fzxyj,valueData:{hjmc:'fzxyj'}})
        },
        // 意见弹窗
        getInputOpinion(val,valueData){
            //console.log(val,valueData)
            let data = this.form
            data[valueData.hjmc] = val
            // //console.log(this.form.fksyj)
            //   this.form.setFieldsValue({
            //     fksyj:this.form.fksyj,
            //     frsyj:this.form.frsyj,
            //     ffgyj:this.form.ffgyj,
            //     fzxyj:this.form.fzxyj,
            //   });
        },
        checkMan(place,man){
            this.$nextTick(_ => {
                this.modaObj = {place: place,manList: man}
                this.$refs.personnelListRef.personnelListVisible = true
            })
        },
        // 选择人员
        checkPersonnel(place,id,name){
            this.$refs.personnelListRef.personnelListVisible = false
            const data = this.form
            data[place] = name.toString()
            // data[fdbrid] = id.toString(),
            // data[fdbr] = name.toString()
            // let Data = {
            //     jobid: this.form.jobid,
            //     fdbrid: id.toString(),
            //     fdbr: name.toString()
            // }
            // zbFlows(Data).then(res => {
            //   //console.log(res)
            // })
        },
        customRow() {
            return {
                style: {
                    'font-size' : '16px',
                    'text-align' : 'center'
                },
            }
        },
        beforeUpload(e){
            return false
        },
        // 上传附件
        async uploadClick({file}){
            //console.log(file)
                if(!this.form.id){
                    let data = []
                    data = {
                        fqjlx: this.form.fqjlx,
                        fts: this.form.fts.toString(),
                        fsfnnxq: this.form.fsfnnxq == true?'是':'否',
                        fyy: this.form.fyy,
                        fqjkssj: this.form.fqjkssj,
                        fqjjssj: this.form.fqjjssj,
                        fqjksxs: this.form.fqjksxs,
                        fqjjsxs: this.form.fqjjsxs,
                        fsflkbgzdszcs: this.form.fsflkbgzdszcs == true?'是':'否',
                        flkrq: this.form.flkrq==''?'':moment(this.form.flkrq).format('YYYY-MM-DD'),
                        ffhrq: this.form.ffhrq==''?'':moment(this.form.ffhrq).format('YYYY-MM-DD'),
                        id: this.form.id,
                    }
                    const res = await fjAdd(data)
                    //console.log(res)
                    this.form = res.result
                    this.form.id = res.result.id
                    if (res.success) {
                        this.uploadClicka(file,this.form.id)
                    }
                } else {
                this.uploadClicka(file,this.form.id)
            }
        },
        uploadClicka(file,id){
            //console.log(file)
            var that = this
                if(typeof file.uid !== 'undefined') {
                const fileData = new FormData();
                fileData.append("file",file);
                fileData.append("oaid",id);
                //console.log(fileData)
                fjupload(fileData).then(res => {
                    if (res.success) {
                    that.$message.success(res.message)
                    fjlist({foaid:id}).then(res => {
                        that.filesListData = []
                        that.filesListData = res.result.records
                    })
                    } else {
                    that.$message.warning(res.message)
                    }
                })
            }
        },
        // 预览
        openFiles(item){
          if(item.fwjlx.indexOf('pdf') !== -1){
              //console.log()
              window.open(
                  bootConfig[process.env.NODE_ENV].locality_ApI2+YchConstant.SPZX_OA+'/oaFjzyk/downLoadOa?id='+item.id
              )
            } else {
              openFile({id:item.id}).then(res => {
                if(!res.success){
                      this.$message.warning('当前附件类型不支持预览,请下载查看')
                } else {
                    window.open(res.result.wordUrl, '_blank')
                }
              })
            }
        },
        // 下载附件
        downloadFiles(val){
            //console.log('下载',val)
            var that = this
            var fileName = val.fmc
            downLoadOa({id:val.id}).then((data) => {
                // //console.log(data)
                if (!data) {
                    that.$message.warning('文件下载失败')
                    return
                }
                let url = window.URL.createObjectURL(new Blob([data], { type: blobType.type[blobType.suffix.indexOf(val.fwjlx)] }))
                let link = document.createElement('a')
                link.style.display = 'none'
                link.href = url
                link.setAttribute('download', fileName)
                document.body.appendChild(link)
                link.click()
                document.body.removeChild(link) //下载完成移除元素
                window.URL.revokeObjectURL(url) //释放掉blob对象
                // this.vxModal.visabled = false;
            })
        },
        // 删除附件
        deleteFiles(idd){
            //console.log('idd',idd)
            deleleMinioFile({id:idd}).then(res => {
                if(res.code == 200){
                this.$message.success('删除成功')
                fjlist({foaid:this.form.id}).then(res => {
                    this.filesListData = []
                    this.filesListData = res.result.records
                })
                } else {
                this.$message.warning(res.message)
                }
            })
        },
        getUrl(ids){
            let url = ''
            this.imgList.forEach(item => {
                if(item.fhjmc == ids){
                url = item.url
                }
            })
            // //console.log('长度',url.length)
            return url
        },
        // 数据修订
        editForm(){
            //console.log(this.form.flkrq)
            //console.log(this.form.ffhrq)
            let data = {
                fbm : this.form.fbm,
                fbz : this.form.fbz,
                ffgqm : this.form.ffgqm,
                ffgqmsj : this.form.ffgqmsj,
                ffgyj : this.form.ffgyj,
                ffhrq : this.form.ffhrq==''||this.form.ffhrq==null?'':moment(this.form.ffhrq).format('YYYY-MM-DD'),
                fksqm : this.form.fksqm,
                fksqmsj : this.form.fksqmsj,
                fksyj : this.form.fksyj,
                flczt : this.form.flczt,
                flkrq : this.form.flkrq==''||this.form.flkrq==null?'':moment(this.form.flkrq).format('YYYY-MM-DD'),
                fmdd : this.form.fmdd,
                fqjjssj : this.form.fqjjssj,
                fqjkssj : this.form.fqjkssj,
                fqjksxs: this.form.fqjksxs,
                fqjjsxs: this.form.fqjjsxs,
                fqjlx : this.form.fqjlx,
                fqjsm : this.form.fqjsm,
                fqtjlx : this.form.fqtjlx,
                frsqm : this.form.frsqm,
                frsqmsj : this.form.frsqmsj,
                frsyj : this.form.frsyj,
                fsffqlc : this.form.fsffqlc,
                fsflkbgzdszcs : this.form.fsflkbgzdszcs == true?'是':'否',
                fsfnnxq : this.form.fsfnnxq == true?'是':'否',
                fsjyy : this.form.fsjyy,
                fts : this.form.fts.toString(),
                fxm : this.form.fxm,
                fyy : this.form.fyy,
                fzw : this.form.fzw,
                fzxqm : this.form.fzxqm,
                fzxqmsj : this.form.fzxqmsj,
                fzxyj : this.form.fzxyj,
                id : this.form.id,
            }
            edit(data).then(res => {
                if(res.code == 200){
                this.$message.success(res.message)
                this.closeVisible()
                } else {
                this.$message.warning(res.message)
                }
            })
        },
        // 退回意见确认
        returnClick(){
            this.$refs.ruleForm.validate(valid => {
                if (valid){
                    queryAllYbJob({jobid:this.form.jobid}).then(res => {
                        let list = res.result
                        list.forEach(item => {
                            if(item.fhjmc == '请假申请'){
                                this.returnFuntion(this.form.jobid,item.id)
                            }
                        })
                    })
                }
            })
        },
        returnFuntion(jobid,ids){
            let returnStr = ''
            if(this.linkName == '科室审批'){
                returnStr = this.form.fksyj
            } else if(this.linkName == '人事审批'){
                returnStr = this.form.frsyj
            } else if(this.linkName == '分管审批'){
                returnStr = this.form.ffgyj
            } else if(this.linkName == '中心领导审批'){
                returnStr = this.form.fzxyj
            }
            let data = {
                jobid: jobid,
                opinion: returnStr,
                shjid: ids,
                smgflag: '',
                smsContent: '',
            }
            returnUpperzdyFlowJob(data).then(res => {
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.closeVisible()
                } else {
                    this.$message.error(res.message)
                }
            })
        },
    },
}
</script>
<style>
@import url('../../css/oaLess.css');
@import url('../../css/oaClass.css');
</style>
